package com.glela.order.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.glela.order.model.OrderInfo;
import com.glela.order.model.OrderObject;
import com.glela.order.vo.OrderInfoVo;

public interface OrderInfoMapper {

	int deleteByPrimaryKey(Long id);

	int insert(OrderInfo record);

	int insertSelective(OrderInfo record);

	OrderInfo selectByPrimaryKey(Long id);

	int updateByPrimaryKeySelective(OrderInfo record);

	int updateByPrimaryKey(OrderInfo record);

	int batchInsert(List<OrderInfo> list);

	int batchUpdateCommisionFeeAndPointFeeById(List<OrderInfo> list);

	/**
	 * <dl>
	 * <dt>查询可分佣订单</dt>
	 * <dd>订单状态已完成且不在售后中</dd>
	 * </dl>
	 * @param orderObjectList item.id
	 * @return List<OrderInfo>
	 * @author zls
	 */
	List<OrderInfo> selectOrderInfoInOOIdForCommision(List<OrderObject> orderObjectList);
	
	public List<Long> selectOrderByOrderSnList(@Param("listOrderSn")List<String> listOrderSn);


	/**
	 * <dl>
	 * <dt>更新订单状态为交易已成功</dt>
	 * <dd>订单状态为已完成</dd>
	 * </dl>
	 * @param orderObjectList item.id 交易单id
	 * @return int
	 * @author zls
	 */
	int updateStatusInOrderObjectId(List<OrderObject> orderObjectList);

	public int updateOrderInfoPayByOrderObjectId(@Param("orderObjectId") long orderObjectId, @Param("bankIn") int bankIn, @Param("procedureFee") int procedureFee, @Param("payType") int payType, @Param("paymentFee") int paymentFee, @Param("payId") String payId, @Param("payTime") String payTime);
	
	public List<OrderInfoVo> selectOrderInfoVoByStatusOrderObjectSn(@Param("orderSn") String orderSn,@Param("status") Integer status);

	/**
	 * 某个用户待发货的订单个数
	 * 
	 * @author 卫耀华
	 * 
	 * @param userId
	 * @return
	 */
	int selectNeedToSendGoodsOrderNum(Long userId);

	/**
	 * 某个用户待收货的订单个数
	 * 
	 * @author 卫耀华
	 * 
	 * @param userId
	 * @return
	 */
	int selectNeedToReceiveGoodsOrderNum(Long userId);

	/**
	 * 总销售额
	 * 
	 * @author houmf
	 * @param id
	 * @return
	 */
	public int selectcountorderinfototalfee(List<Integer> list);

	/** MaoZeYao **/

	/**
	 * 更新子订单的评论状态为已评价
	 * 
	 * @return
	 */
	int updateOrderInfoToComment(Long orderInfoId);

	/**
	 * 根据父订单ID查询子订单的数量
	 * 
	 * @param orderObjectId
	 * @return
	 */
	int selectOrderInfoByOrderObjectId(Long orderObjectId);
	
	List<OrderInfo> selectOrderInfoByOrderObjectSn(@Param("orderSn") String orderSn);

	/**
	 * 根据父订单ID查询子订单评论完成的数量
	 * 
	 * @param orderObjectId
	 * @return
	 */
	int selectOrderInfoCommentCompliteByOrderObjectId(Long orderObjectId);

	/** MaoZeYao **/

	/**
	 * 根据订单状态查询
	 * 
	 * @author houmf
	 * @param id
	 * @return
	 */
	public List<OrderInfo> selectOrderInfoByStatusAndUserId(@Param("userId") long userId, @Param("status") int status,
			@Param("page") int page, @Param("pageSize") int pageSize);

	/**
	 * 查询所有订单
	 * 
	 * @author houmf
	 * @param id
	 * @return
	 */
	public List<OrderInfo> selectOrderInfoAllByUserId(@Param("userId") long userId, @Param("page") int page,
			@Param("pageSize") int pageSize);

	/**
	 * 查询达人订单
	 * 
	 * @author houmf
	 * @param id
	 * @return
	 */
	public OrderInfo selectOrderInfoAllById(long id);

	/**
	 * 查询达人订单状态
	 * 
	 * @author houmf
	 * @param id
	 * @return
	 */
	public OrderInfo selectOrderInfoAllByIdAndStatus(@Param("id") long id, @Param("status") int status);

	/**
	 * 根据订单号查询订单详情
	 * 
	 * @author
	 * @param id
	 * @return
	 */
	public OrderInfo selectOrderInfoEntityByOrderSn(String orderSn);

	/**
	 * 根据快递公司编号和订单编号查询订单信息
	 * 
	 * @author
	 * @param id
	 * @return
	 */
	public OrderInfo selectOrderInfoEntityByExpressCodeAndexpressNo(@Param("expressCode") String expressCode,
			@Param("expressNo") String expressNo);

	/**
	 * 根据订单id查询订单详情
	 * 
	 * @author houmf
	 * @param id
	 * @return
	 */
	public OrderInfo selectOrderInfoEntityById(long id);

	public List<OrderInfo> selectOrderInfoByOrderObjectIdC(long orderObjectId);

	/**
	 * 根据用户id查询待收货订单数量
	 * 
	 * @author houmf
	 * @param id
	 * @return
	 */
	public int selectOrderInfodaishouhuoByUserId(long userId);

	/**
	 * 查询待评价订单
	 * 
	 * @author houmf
	 * @param id
	 * @return
	 */
	public List<OrderInfo> selectOrderInfoStatusInfour(@Param("userId") long userId, @Param("page") int page,
			@Param("pageSize") int pageSize);

	
	/** MaoZeYao **/
	/**
	 * 修改子订单的状态为取消 5
	 * 
	 * @param orderInfoId
	 * @param status
	 * @return
	 */
	int updateOrderInfoStatusByOrderObjectId(@Param("orderInfoId") Long orderInfoId, @Param("status") int status,
			@Param("updateTime") String updateTime);

	/**
	 * 根据父订单的ID修改子订单的评论状态
	 * 
	 * @param id
	 * @return
	 */
	int updateOrderInfoToCommentByOrderObjectId(Long orderObjectId);

	int updateOrderInfoCommentStatusInRedfund(Long orderObjectId);

	/** MaoZeYao **/

	/**
	 * 某个用户待评价的订单个数
	 * 
	 * @param userId
	 * @return
	 */
	int selectNeedToJudgeOfOrderNum(Long userId);
	
	public int updateComAndNoByOrderSn(@Param("expressCode")String expressCode,@Param("expressNo")String expressNo,@Param("expressName")String expressName
			,@Param("orderSn")String orderSn,@Param("sendTime")String sendTime);

	int updateExpressCompanyByOrderSn(@Param("expressNo")String com,@Param("expressName") String company,@Param("orderSn") String orderSn);

	int updateOrderInfoStatusById(@Param("orderInfoId") Long orderInfoId, @Param("status") int status, @Param("updateTime") String updateTime);

	int updateOrderInfoRefundByFlag(Long orderInfoId);

	int selectOrderInfoIsRefundCountByOrderObjectId(Long orderObjectId);

	int selectOrderInfoCountByOrderObjectId(Long orderObjectId);
	/**
	 * 查询状态为三的子订单数量根据父订单id
	 * @param orderObjectId
	 * @return
	 */
	public int selectOrderInfoInShippedByOrderObjectId(long orderObjectId);
	
	public int selectOrderInfoInWaitByOrderObjectId(long orderObjectId);

	List<OrderInfo> selectOrderInfoIdByStatusThree();
	
	public int selectOrderInfoByOrderObjectIdOther(long orderObjectId);

	int updateOrderInfoCompanyAndJobNoById(@Param("orderInfoId")long orderInfoId,@Param("companyId") Integer companyId,
			@Param("jobNo")String jobNo);

	int updateConfirmTime(@Param("orderInfoId")long orderInfoId,@Param("confirmTime") String confirmTime);

    int selectNeedToSendGoodsOrderNumBatch(@Param("userIds") List<Long> userIds);

	int selectNeedToReceiveGoodsOrderNumBatch(@Param("userIds")List<Long> userIds);

	int selectNeedToJudgeOfOrderNumBatch(@Param("userIds") List<Long> userIds);

    int selectfinishedGoodsOrderNumBatch(@Param("userIds") List<Long> userIds);
}
